import { fileURLToPath, URL } from "node:url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import VueDevTools from "vite-plugin-vue-devtools";
import Layouts from "vite-plugin-vue-layouts";
import Pages from "vite-plugin-pages";

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		vue(),
		vueJsx(),
		// VueDevTools(),
		Pages({
			dirs: "src/views",
			exclude: ["**/components/*.vue"],
		}),
		Layouts({
			layoutsDirs: "src/layout",
			// defaultLayout: "default",
		}),
	],
	resolve: {
		alias: {
			"@": fileURLToPath(new URL("./src", import.meta.url)),
		},
	},
	// define: {
	// 	"process.env": {},
	// },
	base: "./", // 设置打包路径
	server: {
		host: "0.0.0.0",
		port: 4399, // 设置服务启动端口号
		open: true, // 设置服务启动时是否自动打开浏览器
		cors: true, // 允许跨域

		// 设置代理，根据我们项目实际情况配置
		// proxy: {
		// 	"/api": {
		// 		target: "http://10.1.23.80:8688/trade-delivery/",
		// 		changeOrigin: true,
		// 		pathRewrite: {
		// 			"^/api": "",
		// 		},
		// 	},
		// },
	},
	build: {
		cssCodeSplit: false,
		assetsInlineLimit: 40960,
		// outDir: "build",
	},
	css: {
		preprocessorOptions: {
			less: {
				modifyVars: {
					// "arcoblue-6": "#f85959",
				},
				javascriptEnabled: true,
			},
		},
	},
});
